package vno.fux.character
{
	import com.mosesSupposes.bitmap.InteractivePNG;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	
	import vno.fux.CompassDirection;
	import vno.fux.res.pool.NpcResource;
	import vno.fux.res.pool.PNGAttacher;
	import vno.fux.res.pool.ResourceAttacher;
	import vno.fux.res.pool.ResourcePool;
	
	public class NpcView extends BaseCharacterView
	{
		public function NpcView(model_:BaseCharacterModel, controller_:BaseCharacterController)
		{
			super(model_, controller_);
			
			this.mouseEnabled = false;
			
			var pic:PNGAttacher = new PNGAttacher;
			pic.addEventListener(ResourceAttacher.RECIEVE, recieveHandler);
			(ResourcePool.getInstance().chaRes.getRes(_model.resId) as NpcResource).pic.attach(pic);
			this.content = pic;
			//this.setRegPoint(CompassDirection.CENTER);
			this.x = _model.pos.x;
			this.y = _model.pos.y;
			pic.mouseEnabled = true;
			pic.addEventListener(MouseEvent.CLICK, clickHandler);
			this.addEventListener(MouseEvent.MOUSE_OVER,light);
			this.addEventListener(MouseEvent.MOUSE_OUT,lightoff);
			this.setRegPoint(CompassDirection.CENTER);
		}
		
		protected function recieveHandler(event:Event):void
		{
			this.refreshRegPoint();
		}
		
		private function light(evt:Event):void
		{
			var testfilters:Array = new Array;
			testfilters.push(new GlowFilter(0x000000));
			evt.target.filters = testfilters;
		}
		private function lightoff(evt:Event):void
		{
			evt.target.filters = null;
		}
		
		private function clickHandler(event:MouseEvent):void//fux
		{
			(this._controller as NpcController).handleClick(event);
		}
		override public function update(evt:Event):void
		{
			
		}
	}
}